package com.cr.admin.business.store.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cr.admin.business.banner.pojo.entity.Banner;
import com.cr.admin.business.store.mapper.StoreMapper;
import com.cr.admin.business.store.pojo.entity.Store;
import com.cr.admin.business.store.pojo.query.StoreQuery;
import com.cr.admin.business.store.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class StoreServiceImpl implements StoreService {

    @Autowired
    private StoreMapper storeMapper;
    @Override
    public List<Store> list(StoreQuery storeQuery) {
        if(storeQuery.getCityId()==null){
            QueryWrapper<Store> queryWrapper= new QueryWrapper<>();
            if(storeQuery.getName()!=null){
                queryWrapper.like("name",storeQuery.getName());
            }
            if(storeQuery.getAddress()!=null){
                queryWrapper.like("address",storeQuery.getAddress());
            }
            return storeMapper.selectList(queryWrapper);
        }
        return storeMapper.selectListWithCityId(storeQuery.getCityId());
    }
}
